package com.wz.jiangsu.main.vav;

import java.time.LocalDate;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author wangzhou
 * @version 1.0
 * @date 2025/3/19 19:08
 */
public class TestB {
    private int a;

    public static void main(String[] args) throws Exception {
        ReentrantLock reentrantLock = new ReentrantLock();
        Condition condition = reentrantLock.newCondition();

        new Thread(( )-> {
            reentrantLock.lock();
            System.out.println("today is " + LocalDate.now());
            try {
                condition.await();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("now is " + LocalDate.now() + " ====== ");
            reentrantLock.unlock();
        });


        new Thread(() -> {
            System.out.println("子线程");
            System.out.println(Thread.currentThread().getName() + "----");
            condition.signal();
        });
        Thread.sleep(60000);
    }

    private boolean flag;
    private static volatile TestB testB  = null;
    private TestB() {

    }

    public static TestB gettInstance(){
        if(testB == null){
            synchronized(TestB.class){
                if(testB == null){
                    testB = new TestB();
                }
            }

        }
        return testB;
    }
}
